<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>酒店信息系统</title>
<link type="text/css" rel="stylesheet"  href="__PUBLIC__/css/style.css">
<link type="text/css" rel="stylesheet"  href="__PUBLIC__/css/page.css" />

<script src="__PUBLIC__/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript">
function checkallstu(o) {
	if(o.checked){
		$("input[name='roombox']").attr("checked",true);
	}else{
		$("input[name='roombox']").attr("checked",false);
	}
}
function aadd(){
	$("#show").show();
}

function delall(){
    var arr="";
    $("input[name=roombox]:checked").each(function(){
    	arr+=$(this).val()+",";
    })
    if(arr==""){
    	alert('请选择要删除的记录');
		return false; 
    }
    if (confirm("您确定要删除吗？")){
         $.post("__APP__/admin/delallhotelArea",{
    	arr : arr
	    }, function(data) {
		if(data.msg=="1"){
			alert("删除成功");
			location.reload();
		}else{
			alert("删除失败");
	    	}
	    },"json");
    }else{
       return false;}
}
function edit(val,flag){
    var json=JSON.parse(val);

	$("#id").val(json.id);
	$("#hotel2").val(json.areaname);
    $("#show").show();
}
function edithotel(val,flag){
    var json=JSON.parse(val);
    var id=json.id;
    $("#areaid").val(json.id);
    $("#areaname").html(json.areaname);
    $.post("__APP__/admin/selecthotelArea",{
        id : id
    }, function(data) {
        var str=data.msg;
        $("#hotelname").val(str);
        $("#showArea_hotel").show();
    },"json");

}


function subsou(){
	var souname = $("#souname").val();
	window.location.href='__APP__/admin/hotelArea?groupname='+souname;
}

function sou_hotel(){
    var movie_sou = $("#hotel_sou").val();
    $.post("__APP__/admin/sou_hotel",{
        arr : movie_sou
    }, function(data) {
        if(data.msg=="1"){
            var json=data.moviesArr;
            var length=json.length;
            var i=1;
            var tempData = "";
            for (var data in json){
                if((i%4)==1){
                    tempData  =  tempData + "<tr class='ctt_white'> <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'><\/td><td align='left' width='90px'>"+json[data].hotel+"<\/td>";
                }else if((i%4)==0){
                    tempData  =  tempData + " <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'><\/td><td align='left' width='90px'>"+json[data].hotel+"<\/td><\/tr>";
                }else {
                    tempData  =  tempData + " <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'><\/td><td align='left' width='90px' >"+json[data].hotel+"<\/td>";
                }
                i++;
            }
            if(length%4){
                var n=2*(4-length%4);
                tempData  =  tempData +"<td colspan='"+n+"' ></td><\/tr>";
            }
            $("#showhotel").show();
            $("#hotel_ss").html(tempData);
        }else{
            alert("删除失败");
        }
    },"json");
}

function showinfo(){
    var data='{$hotelsArr}';
    var json=JSON.parse(data);
    var tempData = "";
    var length=json.length;
    var i=1;
    var per=$("#hotelname").val();
    for (var data in json){
        var checked = '';
        var patt1=new RegExp(json[data].hotel);
        var re=patt1.exec(per);
        if(re){
            checked = 'checked';
        }

        if((i%4)==1){
            tempData  =  tempData + "<tr class='ctt_white'> <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'" + checked +"><\/td><td align='left' width='90px'>"+json[data].hotel+"<\/td>";
        }else if((i%4)==0){
            tempData  =  tempData + " <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'" + checked +"><\/td><td align='left' width='90px'>"+json[data].hotel+"<\/td><\/tr>";
        }else {
            tempData  =  tempData + " <td align='right'><input  type='checkbox' name='hotelbox' id='hotelbox'  value='"+json[data].id+"/"+json[data].hotel+"'" + checked +"><\/td><td align='left' width='90px' >"+json[data].hotel+"<\/td>";
        }
        i++;
    }
    if(length%4){
        var n=2*(4-length%4);
        tempData  =  tempData +"<td colspan='"+n+"' ></td><\/tr>";
    }
    $("#showhotel").show();
    $("#hotel_ss").html(tempData);

}

function checkallhotel(o) {
    if(o.checked){
        $("input[name='hotelbox']").attr("checked",true);
    }else{
        $("input[name='hotelbox']").attr("checked",false);
    }
}

function sureclick(val){
    var flag=val;

    $("#show"+flag).hide();
    $("#show"+flag+1).hide();
    if(flag=='hotel'){
        var hotelarr="";
        $("input[name=hotelbox]:checked").each(function(){
            hotelarr+=$(this).val()+",";
        })
        //  alert(hotelarr);
        $("#hotelname").val(hotelarr);
    }else{
        var moviearr="";
        $("input[name=moviebox]:checked").each(function(){
            moviearr+=$(this).val()+",";
        })

        $("#moviename").val(moviearr);
    }
}

</script>
</head>

<body>
{include file="public/head"} 

</div>
<div class="content_2 clear">
{include file="admin/left"}
<div class="content_3 left">
  <div class="content_3_wz"><img src="__PUBLIC__/images/dajt.png" />系统管理 &gt; 区域管理</div>
  <div class="content_3_fdj"><img src="__PUBLIC__/images/fdj.jpg" /></div>
  <div class="content_3_xian"></div>
  <div class="content_3_ss clear">
     <ul>
      <li><span class="ctt_wd left">酒店区域查找：</span>
          <input id='souname'  name="text2" type="text" class="layui-input" />
      </li>
      <li class="ss_cx"><a href="#" onClick="subsou()">查询</a></li>
         <li class="ss_cx"><a href="__APP__/admin/operationlog?type=hotelArea">操作日志</a></li>
    </ul>
  </div>
    <table class="layui-table" lay-skin="line" >
   <thead >
      <tr>
        <td width="75">选择</td>
        <td width="85">编号</td>
        <td width="267">酒店区域名</td>


         <td width="180">操作</td>
      </tr>
    </thead>
    <tbody>
     <?
     if($roomArr){
      foreach($roomArr as $val){
        $tmp = addslashes(json_encode($val));
     ?>
      <tr >
        <td><input  type="checkbox" name="roombox" id="roombox"  value="{$val[id]}"></td>
        <td>{$val[id]}</td>
        <td>{$val[areaname]}</td>

        <td>
        <a href="#" class="layui-btn layui-btn-sm" onclick='edit("{$tmp}",2)'>修改 </a>
            <a href="#" class="layui-btn layui-btn-sm" onclick='edithotel("{$tmp}",2)'>关联酒店 </a>
        </td>
      </tr>
    <?php 
		}
	}?>
    </tbody>
  </table>
  <div class="content_1234">
    <div class="content_glcz">管理操作：全选
      <input type="checkbox"  onClick="checkallstu(this)" />
        <input name="submit" type="submit" value="删除"  onclick="delall()" class="layui-btn layui-btn-sm layui-btn-warm"/>
        <input name="submit2" type="button" value="添加区域" onclick="aadd()" class="layui-btn layui-btn-sm"/>
    </div>
    <div class="layui-box layui-laypage layui-laypage-default">{$page}</div>
  </div>

    <FORM action="__APP__/admin/addhotelArea" enctype="multipart/form-data"method="post" >
        <div id="show" style="DISPLAY:none" class="show">
            <table class="layui-table" lay-skin="line">
               <thead >
                <tr>
                    <td colspan="2">酒店区域管理</td>
                    <input type="hidden" id="id" name="id">

                </tr>
                </thead>
                <tbody>
                <tr class="ctt_gr">
                    <td width="154" align="right">酒店区域：</td>
                    <td width="338" align="left">
                        <input class="textField_hp1"  size="20" id="hotel2" name="areaname"/>
                    </td>
                </tr>

                <tr class="ctt_gr">
                    <td height="31" colspan="2" align="center"><input name="submit22" type="submit" value="确定" border="0"  class="layui-btn" id="ok"/>
                        <input name="submit22" type="button" value="取消" border="0" onclick="document.getElementById
	('show').style.display='none'" class="layui-btn layui-btn-warm"/></td>
                </tr>
                </tbody>
            </table>
        </div>

    </FORM>

    <FORM action="__APP__/admin/join_hotel_Area" enctype="multipart/form-data"method="post" >
        <div id="showArea_hotel" style="DISPLAY:none" class="show">
            <table class="layui-table" lay-skin="line">
               <thead >
                <tr>
                    <td colspan="2">酒店区域管理</td>
                    <input type="hidden" id="areaid" name="areaid">

                </tr>
                </thead>
                <tbody>
                <tr class="ctt_gr">
                    <td width="154" align="right">酒店区域：</td>
                    <td width="338" align="left"><span  id="areaname" name="areaname"></span>

                    </td>
                </tr>
                <tr class="ctt_gr">
                    <td  align="right">酒店名：</td>
                    <td align="left"><input  type="text" name="hotelname" id="hotelname"  readonly="readonly">
                        <input name="button" type="button"  onclick="showinfo()" value="选择酒店"  class="btn_01"/></td>

                </tr>


                <tr class="ctt_gr">
                    <td height="31" colspan="2" align="center"><input name="submit22" type="submit" value="确定" border="0"  class="layui-btn" id="ok"/>
                        <input name="submit22" type="button" value="取消" border="0" onclick="document.getElementById
	('showArea_hotel').style.display='none'" class="layui-btn layui-btn-warm"/></td>
                </tr>
                </tbody>
            </table>
        </div>

    </FORM>

    <div id="showhotel" style="DISPLAY:none" class="show">
        <table class="layui-table" lay-skin="line">
           <thead >
            <tr>
                <td colspan="8">酒店列表</td>
            </tr>
            <tr>
                <td class="ctt_white" colspan="7" align="center">酒店名：<input  type="text" name="movie_sou" id="hotel_sou" >
                    <input name="button" type="button"  onclick="sou_hotel()"  value="查询" border="0" />
                </td>
                <td class="ctt_white">全选：
                    <input name="checkbox" type="checkbox" onClick="checkallhotel(this)" />
                </td>
            </tr>
            </thead>
            <tbody id="hotel_ss">

            </tbody>
            <tfoot>
            <tr class="ctt_gr">
                <td height="31" colspan="8" align="center"><input name="button" type="button"  onclick="sureclick('hotel')"  value="确定" border="0"  class="layui-btn"/>
                    <input name="submit22" type="button" value="关闭" border="0" onclick="document.getElementById
	('showhotel').style.display='none'" class="layui-btn layui-btn-warm"/></td>
            </tr>
            </tfoot>
        </table>
    </div>

</div>
</div>
</body>
</html>
